<template>
  <!-- elementUI的轮播图组件 -->
  <div class="block">
    <!-- 这里设置轮播容器的高度 -->
    <el-carousel height="200px">
      <el-carousel-item v-for="item in banners" :key="item.id">
        <slot></slot>
        <a :href="item.link"><img :src="item.image" alt="" /></a>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
export default {
  name: "Swipper",
  // 获取首页创建时请求到的轮播数据
  props: {
    banners: {
      type: Array,
      default() {
        return [];
      },
    },
  },
};
</script>

<style>
img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
</style>